#ifndef _GD25Q_CMD_H_
#define	_GD25Q_CMD_H_

#include "stdint.h"
#include "gd25q_hal.h"

// command list
#define GD25CMD_Write_Enable                              0x06
#define GD25CMD_Write_Disable                             0x04
#define GD25CMD_SRWrite Enable                            0x50
#define GD25CMD_Read_StReg1                               0x05
#define GD25CMD_Read_StReg2                               0x35
#define GD25CMD_Read_StReg3                               0x15
#define GD25CMD_Write_StReg1                              0x01
#define GD25CMD_Write_StReg2                              0x31
#define GD25CMD_Write_StReg3                              0x11
#define GD25CMD_Read_Data                                 0x03
#define GD25CMD_Fast_Read                                 0x0B
#define GD25CMD_Dual_Output                               0x3B
#define GD25CMD_Dual_IO                                   0xBB
#define GD25CMD_Quad_Output                               0x6B
#define GD25CMD_Quad_IO                                   0xEB
#define GD25CMD_Quad_IO_Word                              0xE7
#define GD25CMD_Page_Program                              0x02
#define GD25CMD_Quad_Page_Program                         0x32
#define GD25CMD_Sector_Erase                              0x20
#define GD25CMD_Block_Erase_32K                           0x52
#define GD25CMD_Block_Erase_64K                           0xD8
#define GD25CMD_Chip_Erase                                0x60
#define GD25CMD_Enable_QPI                                0x38
#define GD25CMD_Enable_Reset                              0x66
#define GD25CMD_Reset                                     0x99
#define GD25CMD_Set_Burst_with_Wrap                       0x77
#define GD25CMD_Erase SecurityReg                         0x44
#define GD25CMD_Program SecurityReg                       0x42
#define GD25CMD_Read SecurityReg                          0x48
#define GD25CMD_Individual_Block_Lock                     0x36
#define GD25CMD_Individual_Block_Unlock                   0x39
#define GD25CMD_Read_Block_Lock                           0x3D
#define GD25CMD_Global_Block_Lock                         0x7E
#define GD25CMD_Global_Block_Unlock                       0x98

// flash information
#define GD25Q128_PAGE_SIZE                                0x100UL          //256bytes 
#define GD25Q128_PAGE_MASK                                0xFFUL
#define GD25Q128_SECTOR_SIZE                              0x1000UL         //4kbytes
#define GD25Q128_SECTOR_MASK                              0xFFFUL
#define GD25Q128_BLOCK_SIZE                               0x8000UL         //32kbytes
#define GD25Q128_BLOCK_MASK                               0x7FFFUL
#define GD25Q128_CHIP_SIZE                                0x1000000UL      //16mbytes
#define GD25Q128_CHIP_MASK                                0xFFFFFFUL

// statue define
#define GD25Q_ST_BUSY_MASK                                0x01
#define GD25Q_ST_WRITE_EN                                 0x02

// mode
#define GD25Q_READ                                        0x00
#define GD25Q_WRITE                                       0x01

//function
uint32_t gd25qCmdStRead(void);
uint8_t  gd25qBusy(void);


void gd25qCmdWriteEn(void);
void gd25qCmdWriteDis(void);
void gd25qSectorErase(uint32_t addr);
void gd25qBlockErase(uint32_t addr);
void gd25qChipErase(void );

void gd25qRead(uint32_t addr,uint32_t Len,uint8_t *Des);
void gd25qWrite(uint32_t addr,uint32_t Len,uint8_t *Src);
void gd25qDmaRead(uint32_t addr,uint32_t Len,uint8_t *Des);
void gd25qDmaWrite(uint32_t addr,uint32_t Len,uint8_t *Src);

#endif	/* _GD25Q_CMD_H_ */

